package lol

import (
	"gitee.com/startbbq/go-package/strval"
	"github.com/GoAdminGroup/go-admin/context"
	"github.com/GoAdminGroup/go-admin/modules/db"
	"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table"
	"github.com/GoAdminGroup/go-admin/template/types"
	"github.com/GoAdminGroup/go-admin/template/types/form"
	"github.com/gogf/gf/frame/g"
)

func GetLolHeroSkillsTable(ctx *context.Context) table.Table {

	lolHeroSkills := table.NewDefaultTable(table.DefaultConfigWithDriver("sqlite"))

	info := lolHeroSkills.GetInfo().HideFilterArea()

	info.AddField("Id", "id", db.Int).
		FieldSortable().
		FieldEditAble()
	info.AddField("等级", "is_grade", db.Tinyint).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("被动主要：1是0否", "passive_main", db.Tinyint).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("被动技能cd", "passive_skills", db.Double).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("被动技能标题", "passive_title", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("被动技能说明", "passive_explain", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("Q主要：1是0否", "q_main", db.Tinyint).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("Q技能cd", "q_skills", db.Double).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("Q技能标题", "q_title", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("Q技能说明", "q_explain", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("W主要：1是0否", "w_main", db.Tinyint).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("W技能cd", "w_skills", db.Double).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("W技能标题", "w_title", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("W技能说明", "w_explain", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("E主要：1是0否", "e_main", db.Tinyint).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("E技能cd", "e_skills", db.Double).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("E技能标题", "e_title", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("E技能说明", "e_explain", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("R主要：1是0否", "r_main", db.Tinyint).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("R技能cd", "r_skills", db.Double).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()
	info.AddField("R技能标题", "r_title", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("R技能说明", "r_explain", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("关联英雄id", "cid", db.Int).
		FieldFilterable().
		FieldSortable().
		FieldEditAble()

	info.AddField("背景故事", "is_story", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("友方使用", "friendly_use", db.Varchar).
		FieldFilterable().
		FieldEditAble()
	info.AddField("敌方使用", "enemy_use", db.Varchar).
		FieldFilterable().
		FieldEditAble()

	info.SetTable("lol_hero_skills").SetTitle("技能").SetDescription("LolHeroSkills")

	formList := lolHeroSkills.GetForm()
	formList.AddField("Id", "id", db.Int, form.Number).
		FieldDefault("0")
	formList.AddField("等级", "is_grade", db.Tinyint, form.Number).
		FieldDefault("0")
	formList.AddField("被动主要", "passive_main", db.Tinyint, form.Switch).
		// switch的选项，Text代表显示内容，Value代表对应值
		FieldOptions(types.FieldOptions{
			{Text: "是", Value: "1"},
			{Text: "否", Value: "0"},
		}).
		FieldDefault("0") // 设置默认的值
	formList.AddField("被动技能cd", "passive_skills", db.Double, form.Currency).
		FieldDefault("0")
	formList.AddField("被动技能标题", "passive_title", db.Varchar, form.Text)
	formList.AddField("被动技能说明", "passive_explain", db.Varchar, form.TextArea)
	formList.AddField("Q主要", "q_main", db.Tinyint, form.Switch).
		// switch的选项，Text代表显示内容，Value代表对应值
		FieldOptions(types.FieldOptions{
			{Text: "是", Value: "1"},
			{Text: "否", Value: "0"},
		}).
		FieldDefault("0") // 设置默认的值
	formList.AddField("Q技能cd", "q_skills", db.Double, form.Currency).
		FieldDefault("0")
	formList.AddField("Q技能标题", "q_title", db.Varchar, form.Text)
	formList.AddField("Q技能说明", "q_explain", db.Varchar, form.TextArea)
	formList.AddField("W主要", "w_main", db.Tinyint, form.Switch).
		// switch的选项，Text代表显示内容，Value代表对应值
		FieldOptions(types.FieldOptions{
			{Text: "是", Value: "1"},
			{Text: "否", Value: "0"},
		}).
		FieldDefault("0") // 设置默认的值
	formList.AddField("W技能cd", "w_skills", db.Double, form.Currency).
		FieldDefault("0")
	formList.AddField("W技能标题", "w_title", db.Varchar, form.Text)
	formList.AddField("W技能说明", "w_explain", db.Varchar, form.TextArea)
	formList.AddField("E主要", "e_main", db.Tinyint, form.Switch).
		// switch的选项，Text代表显示内容，Value代表对应值
		FieldOptions(types.FieldOptions{
			{Text: "是", Value: "1"},
			{Text: "否", Value: "0"},
		}).
		FieldDefault("0") // 设置默认的值
	formList.AddField("E技能cd", "e_skills", db.Double, form.Currency).
		FieldDefault("0")
	formList.AddField("E技能标题", "e_title", db.Varchar, form.Text)
	formList.AddField("E技能说明", "e_explain", db.Varchar, form.TextArea)
	formList.AddField("R主要", "r_main", db.Tinyint, form.Switch).
		// switch的选项，Text代表显示内容，Value代表对应值
		FieldOptions(types.FieldOptions{
			{Text: "是", Value: "1"},
			{Text: "否", Value: "0"},
		}).
		FieldDefault("0") // 设置默认的值
	formList.AddField("R技能cd", "r_skills", db.Double, form.Currency).
		FieldDefault("0")
	formList.AddField("R技能标题", "r_title", db.Varchar, form.Text)
	formList.AddField("R技能说明", "r_explain", db.Varchar, form.TextArea)

	lol_hero, _ := g.DB().Model("lol_hero").All()
	var hero_st types.FieldOptions
	for _, v := range lol_hero {
		hero_st = append(hero_st, types.FieldOption{
			Text:  strval.Strval(v["hero_keyword"]),
			Value: strval.Strval(v["id"]),
		})
	}
	formList.AddField("关联英雄id", "cid", db.Int, form.SelectSingle).
		// 多选的选项，text代表显示内容，value代表对应值
		FieldOptions(hero_st).
		// 设置默认值
		FieldDefault("0")

	formList.AddField("背景故事", "is_story", db.Varchar, form.TextArea)
	formList.AddField("友方使用", "friendly_use", db.Varchar, form.TextArea)
	formList.AddField("敌方使用", "enemy_use", db.Varchar, form.TextArea)

	formList.SetTable("lol_hero_skills").SetTitle("技能").SetDescription("LolHeroSkills")

	return lolHeroSkills
}
